<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.js"></script>
<script>
var script1 = normalizeURL('resources/empty-worker.js');
var script2 = normalizeURL('resources/empty-worker.js?new');

promise_test(function(t) {
    var scope = 'resources/scope/register-30-times';

    return service_worker_unregister(t, scope)
      .then(function() {
          var promises = [];
          for (var i = 0; i < 15; ++i) {
            promises.push(navigator.serviceWorker.register(script1,
                                                           { scope: scope }));
            promises.push(navigator.serviceWorker.register(script2,
                                                           { scope: scope }));
          }
          return Promise.all(promises);
        })
      .then(function(registrations) {
          return registrations[0].unregister();
        });
  }, 'Repetitive registrations with the same scope should not trigger OOM');

</script>
